<template>
	<view class="preview" >
		<swiper circular>
			<swiper-item v-for="item in 5">
				<image @click="onImgClick" src="../../static/cute.jpg" mode="aspectFill"></image>
			</swiper-item>
		</swiper>
		
		<!-- 悬浮遮罩层 -->
		<view class="mask" v-if="maskState">
			<view class="goBack" @click="goBack"  :style="{ top: getStatusBarHeight() + 'px' }">
				<uni-icons type="goBack" color="#fff" size="20"></uni-icons>
			</view>
			<view class="count">
				3 / 9
			</view>
			<view class="time">
				<!-- hh:mm -->
				<uni-dateformat :date="new Date()" format="hh:mm"></uni-dateformat>
			</view>
			<view class="date">
				<!-- yyyymmdd -->
				<uni-dateformat :date="new Date()" format="MM月dd日"></uni-dateformat>
			</view>
			<view class="footer">
				<view class="box">
					<uni-icons type="info" size="30" @click="clickInfo"></uni-icons>
					<view class="text"> info </view>
				</view>
				<view class="box" @click="clickStar">
					<uni-icons type="star" size="30"></uni-icons>
					<view class="text"> score </view>
				</view>
				<view class="box">
					<uni-icons type="download" size="30"></uni-icons>
					<view class="text"> download </view>
				</view>
			</view>
		</view>
		
		<!-- info弹窗 -->
		<uni-popup ref="infoPopup" type="bottom">
			<view class="infoPopup">
				<view class="popHeader">
					<view></view>
					<view class="title"> i am title </view>
					<view class="close" @click="onInfoClose"> 
						<uni-icons type="closeempty" size="18" color="#999"></uni-icons>
					</view>
				</view>
				<scroll-view scroll-y>
					<view class="content">
						<view class="row">
							<!-- item:{{item}} -->
							<view class="attributeName-label"> id </view>
							<text class="value-label" selectable > i am value </text>
						</view>
						
						<view class="row">
							<!-- item:{{item}} -->
							<view class="attributeName-label"> 分类 </view>
							<text class="value-label type-label" selectable > i am value2 </text>
						</view>
						
						<view class="row">
							<!-- item:{{item}} -->
							<view class="attributeName-label"> 发布者: </view>
							<text class="value-label" selectable > i am value3 </text>
						</view>
						
						<view class="row">
							<!-- item:{{item}} -->
							<view class="attributeName-label"> 评分: </view>
							<view class="value-label rate-box" selectable > 
								<uni-rate readonly touchable value="3.5" size="16"></uni-rate>
								<text class="score"> 5分 </text>
							</view>
						</view>
						<view class="row">
							<!-- item:{{item}} -->
							<view class="attributeName-label"> 标签: </view>
							<view class="value-label tabs" selectable > 
								<view class="tab" v-for="item in 3"> 标签名 </view>
							</view>
						</view>
						<view class="row">
							<!-- item:{{item}} -->
							<view class="attributeName-label"> i am atttribute3: </view>
							<text class="value-label" selectable > i am value3 </text>
						</view>
						<view class="row">
							<!-- item:{{item}} -->
							<view class="attributeName-label"> i am atttribute3: </view>
							<text class="value-label" selectable > i am value3 </text>
						</view>
						
						<view class="copyright">
							声明：本图片来用户投稿，非商业使用，用于免费学习交流，如侵犯了您的权益，您可以拷贝壁纸ID举报至平台，邮箱513894357@qq.com，管理将删除侵权壁纸，维护您的权益。
						</view>
												
					</view>
				</scroll-view>
			</view>
		</uni-popup>
		
		<!-- star弹窗 -->
		<uni-popup ref="scorePopup" :is-mask-click="true">
			<view class="scorePopup">
				<!-- popup弹窗的头部 -->
				<view class="popHeader">
					<view></view>
					<view class="title"> i am title ofscore </view>
					<view class="close" @click="onScoreClose"> 
						<uni-icons type="closeempty" size="18" color="#999"></uni-icons>
					</view>
				</view>
				
				<view class="content">
					<uni-rate v-model="userScore" @change="onChange" allow-half></uni-rate>
					<text class="text"> {{userScore}}分 </text>
				</view>
				
				<view class="footer">
					<button @click="submitScore" :disabled="!userScore" type="default" size="mini" plain> confirm score </button>
				</view>
			</view>
		</uni-popup>
		
	</view>
</template>

<script setup>
import { getStatusBarHeight } from "@/utils/system.js"
import { ref } from 'vue';
	
	const maskState = ref(true);
	const infoPopup = ref(null); //拿到这个popup组件的实例
	const scorePopup = ref(null);
	const userScore = ref(5);
	
	const onImgClick = ()=>{
		maskState.value = !maskState.value;
	}
	
	const clickInfo = ()=>{
		infoPopup.value.open();
	}
	
	const onInfoClose = ()=>{
		infoPopup.value.close();
	}
	
	const clickStar = ()=>{
		scorePopup.value.open();
	}
	
	const onScoreClose = ()=>{
		scorePopup.value.close();
	}
	
	const submitScore = ()=>{
		console.log("pingfenle");
	}
	
	const goBack = ()=>{
		uni.navigateBack();
	}

</script>

<style lang="scss" scoped>
	.preview{
		width: 100%;
		height: 100vh;
		position: relative;
		swiper{
			width: 100%;
			height: 100%;
			image{
				width: 100%;
				height: 100%;
			}
		}
	}
	.mask{
		// 父级紧邻的所有view
		&>view{
			color: #fff;
			position: absolute;
			left: 0;
			right: 0;
			margin: auto;
			// 左右拉扯,请你自便,好,跑到中间了
			// 宽度适应文字长度
			width: fit-content;
		}
		
		.goBack{
			width: 40rpx;
			height: 40rpx;
			background: rgba(0,0,0,0.5);
			left: 30rpx;
			margin-left: 0;
			border-radius: 100rpx;
			top: 0;
			backdrop-filter: blur(10rpx);
			border: 1rpx solid rgba(222,222,222,0.888);
			display: flex;
			align-items: center;
			justify-content: center;
		}
		.count{
			top: 10vh;
			background: rgba(0,0,0,0.2);
			backdrop-filter: blur(10rpx);
			font-size: 30rpx;
			border-radius: 40rpx;
			padding: 10rpx 30rpx;
		}
		.time{
			font-size: 150rpx;
			top: calc(10vh + 80rpx);
			font-weight: 100;
			line-height: 1em; //去掉行高
			text-shadow: 4rpx 4rpx rgba(0,0,0,0.5);
		}
		.date{
			font-size: 35rpx;
			top: calc(10vh + 240rpx);
			text-shadow: 2rpx 2rpx rgba(0,0,0,0.5);
		}
		.footer{
			background: rgba(255,255,255,0.8);
			bottom: 10vh;
			width: 61vw;
			height: 120rpx;
			border-radius: 120rpx;
			color: #000;
			display: flex;
			justify-content: space-around;
			align-items: center;
			box-shadow: 0 2rpx 0 rgba(0,0,0,0.2);
			.box{
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				padding: 2rpx 12rpx;
				border: 1px solid red;
				.text{
					font-size: 25rpx;
					color: #777;
				}
			}
		}
	}
	
	// 两个popup的头部是公用的
	.popHeader{
		display: flex;
		justify-content: space-around;
		align-items: center;
		.title{
			color: text-font-color-2;
			font-size: 30rpx;
		}
		.close{
			border: 1px solid red;
			padding: 5rpx;
		}
		
	}
	
	.infoPopup{
		border: 1px solid red;
		background: #fff;
		// margin: 100rpx;
		width: 100%;
		
		padding: 20rpx;
		border-radius: 30rpx 30rpx 0 0;
		overflow: hidden;
		
		scroll-view{
			max-height: 60vh;
			.content{
				.row{
					display: flex; /* 将父元素设置为Flex容器 */
					justify-content: flex-start; /* 子元素从左到右排列 */
					padding: 15rpx 0;
					font-size: 32rpx;
					line-height: 1.7em;
					.attributeName-label{
						color: $text-font-color-2;
						// width: 150rpx;
						// text-align: right;
						font-size: 30rpx;
					}
					.value-label{
						// display: flex;
						flex: 1;
						width: 0;
					}
					.rate-box{
						display: flex; /* 将父元素设置为Flex容器 */
						justify-content: flex-start; /* 子元素从左到右排列 */
						align-items: center; /* 子元素在父元素的垂直方向居中对齐 */
						align-items: center;
						.score{
							font-size: 25rpx;
							color: $text-font-color-3;
							padding-left: 20rpx;
						}
					}
					.tabs{
						display: flex;
						flex-wrap: wrap;
						margin-left: 20rpx;
						.tab{
							border: 1px solid $theme-green;
							color: $theme-green;
							font-size: 22rpx;
							padding: 10rpx 30rpx;
							border-radius: 40rpx;
							line-height: 1em;
							margin: 0 10rpx 10rpx 0;
						}
					}
					.type-label{
						color: $theme-green;
					}
				}
				.copyright{
					font-size: 30rpx;
					padding: 30rpx;
					background: #f6f6f6;
					color: #777;
					border-radius: 10rpx;
					margin: 20rpx 0;
					line-height: 1.5em;
				}
			}
		}
	}
	
	.scorePopup{
		background: #fff;
		padding: 30rpx;
		width: 70vw;
		border-radius: 30rpx;
		.content{
			padding: 30rpx 0; //上下 左右
			display: flex; //显示在一行f
			justify-content: center;
			align-items: center;
			.text{
				color: #ffc3ae;
				padding-left: 10rpx;
				width: 80rpx;
				line-height: 1em;
				text-align: right;
			}
		}
		.footer{
			padding: 10rpx 0;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
</style>
